import {BrowserRouter ,Routes,Route,Navigate,useRoutes} from 'react-router'
import Register from '../pages/Register'
import React from 'react'
import NoteList from '../pages/NoteList'
const Login = React.lazy(()=>import('../pages/Login'))
const NoteClass = React.lazy(()=>import('../pages/NoteClass'))

const routes=[{
    path:"/",
    element:<Navigate to="/nodeClass" />
},{
    path:"/login",
    element:<Login />
},{
    path:"/noteClass",
    element:<NoteClass />
},{
    path:"/register",
    element:<Register />
},{
    path:"/noteList",
    element:<NoteList />
}
]


function WrapperRoutes(){  //<Routes></Routes>
    let ele = useRoutes(routes)
    return ele
//     //声明路由模式为history模式
// <BrowserRouter>
//   {/* 路由出口,所有路由组件最终都会渲染到这个出口 */}
//   <Routes>
//     {/* 路由项 */}
//     <Route path="/" element={<Navigate to="/nodeClass" />} />
//     <Route path="/login" element={<Login />} />
    
//   </Routes>
// </BrowserRouter>
}
export default function WrapperRouter(){
    return(
        <BrowserRouter>
        <WrapperRoutes/>
        </BrowserRouter>
    )
}